//
//  FootView.swift
//  我的微博
//
//  Created by gongjunna on 15/8/1.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class FootView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        prepareUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var status : Statu? {
    didSet {
        if let url = status?.user?.imageURL {
            iconView.setImageWithURL(url)
        }
        nameLabel.text = status?.user?.name ?? ""
        vipIconView.image = status?.user?.vipImage
        memberIconView.image = status?.user?.memberImage
        // TODO: 后续调整
        timeLabel.text = "刚刚"
        sourceLabel.text = "新浪微博"
    
    }
    
    
    }
    func prepareUI() {
        let vi = UIView()
        vi.backgroundColor = UIColor(white: 0.85, alpha: 1)
        addSubview(vi)
        addSubview(iconView)
        addSubview(vipIconView)
        addSubview(nameLabel)
        addSubview(memberIconView)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        
        vi.ff_AlignInner(type: ff_AlignType.TopRight, referView: self, size: CGSizeMake(UIScreen.mainScreen().bounds.width, 10), offset: CGPoint(x: 0, y: 0))
        iconView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: vi, size: CGSize(width: 35, height: 35), offset: CGPoint(x: 8, y: 8))
        vipIconView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 8))
        nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: 10, y: 0))
        memberIconView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: nameLabel, size: nil, offset: CGPoint.zeroPoint)
        timeLabel.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: nameLabel, size: nil, offset: CGPoint(x: 0, y: 5))
        sourceLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: timeLabel, size: nil, offset: CGPoint(x: 8, y: 0))
        
    
    }
    
     // MARK: - 懒加载控件
    /// 头像
    private lazy var iconView = UIImageView()
    /// vip图标
    private lazy var vipIconView: UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    /// 姓名
    private lazy var nameLabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
    /// 会员图标
    private lazy var memberIconView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    /// 时间
    private lazy var timeLabel = UILabel(color: UIColor.orangeColor(), fontSize: 10)
    /// 来源
    private lazy var sourceLabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 10)
}
